/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controladores;

import entities.Clientes;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateful;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author edgar
 */

public class ClientesController {

    @PersistenceContext
    EntityManager em;

    public List<Clientes> listarClientes() {
        // Context initCtx = new InitialContext();
        //EntityManager em = (javax.persistence.EntityManager) initCtx.lookup("java:comp/env/persistence/sgalds1");
        Query q = em.createNamedQuery("Clientes.findAll", Clientes.class);
        List<Clientes> lista = new ArrayList(q.getResultList());
        return lista;
    }
}
